reference_point = (10, 10)
def I(x, y):
    area_x = (reference_point[0] - x[0]) * (reference_point[1] - x[1])
    area_y = (reference_point[0] - y[0]) * (reference_point[1] - y[1])

    intersection_width = max(min(reference_point[0] - x[0], reference_point[0] - y[0]), 0)
    intersection_height = max(min(reference_point[1] - x[1], reference_point[1] - y[1]), 0)
    intersection_area = intersection_width * intersection_height

    return area_x - intersection_area


def I2(x,y):
    area_x = (reference_point[0] - x[0]) * (reference_point[1] - x[1])
    area_y = (reference_point[0] - y[0]) * (reference_point[1] - y[1])

    if (x[0] <= y[0] and x[1] <= y[1]) or (y[0] <= x[0] and y[1] <= x[1]):
        return area_x - area_y
    else:
        intersection_width = max(min(reference_point[0] - x[0], reference_point[0] - y[0]), 0)
        intersection_height = max(min(reference_point[1] - x[1], reference_point[1] - y[1]), 0)
        intersection_area = intersection_width * intersection_height

        return area_x - intersection_area

s1 = (1, 6)
s2 = (2, 5)
s3 = (3, 7)


# Calculate areas
area = I2(s1,s2)
print(area)

area = I2(s3,s2)
print(area)